package cn.epsilon3.configuration;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @description Caffeine初始化
 *
 * @author: epsilon3
 * @date: 2023/11/07 23:07
 */
@Configuration
public class E3CaffeineConfiguration {
    @Bean(value = "E3CaffeineCache")
    public Cache<String, Object> caffeineCache() {
        return Caffeine.newBuilder()
                .expireAfterAccess(7200, TimeUnit.SECONDS)
                .initialCapacity(100)
                .maximumSize(1000)
                .build();
    }
}
